<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>提示 - 组件演示</title>
    <link rel="stylesheet" href="../css/style.css">
    <link rel="stylesheet" href="../components/tooltip/tooltip.css">
</head>
<body>
    <div class="container">
        <header class="header">
            <h1>🚀 openHarmony_Cordova_NutpiDesign</h1>
            <p class="subtitle">组件演示 - 提示</p>
        </header>

        <nav class="demo-nav">
            <a href="../index.html" class="nav-back">← 返回首页</a>
        </nav>

        <main class="main-content">
            <section class="demo-section">
                <h2>💬 提示演示</h2>
                
                <div class="demo-container">
                    <div class="demo-item">
                        <h3>上方提示</h3>
                        <button id="topTooltip" class="demo-btn">悬停</button>
                    </div>

                    <div class="demo-item">
                        <h3>下方提示</h3>
                        <button id="bottomTooltip" class="demo-btn">悬停</button>
                    </div>

                    <div class="demo-item">
                        <h3>左方提示</h3>
                        <button id="leftTooltip" class="demo-btn">悬停</button>
                    </div>

                    <div class="demo-item">
                        <h3>右方提示</h3>
                        <button id="rightTooltip" class="demo-btn">悬停</button>
                    </div>

                    <div class="demo-item">
                        <h3>点击触发</h3>
                        <button id="clickTooltip" class="demo-btn">点击</button>
                    </div>

                    <div class="demo-item">
                        <h3>聚焦触发</h3>
                        <input id="focusTooltip" type="text" class="demo-input" placeholder="聚焦">
                    </div>

                    <div class="demo-item">
                        <h3>深色主题</h3>
                        <button id="darkTooltip" class="demo-btn">悬停</button>
                    </div>

                    <div class="demo-item">
                        <h3>浅色主题</h3>
                        <button id="lightTooltip" class="demo-btn">悬停</button>
                    </div>

                    <div class="demo-item">
                        <h3>延迟显示</h3>
                        <button id="delayTooltip" class="demo-btn">悬停</button>
                    </div>

                    <div class="demo-item">
                        <h3>长文本提示</h3>
                        <button id="longTooltip" class="demo-btn">悬停</button>
                    </div>

                    <div class="demo-item">
                        <h3>无箭头提示</h3>
                        <button id="noArrowTooltip" class="demo-btn">悬停</button>
                    </div>

                    <div class="demo-item">
                        <h3>自定义宽度</h3>
                        <button id="customWidthTooltip" class="demo-btn">悬停</button>
                    </div>
                </div>
            </section>

            <section class="demo-section">
                <h2>使用代码</h2>
                <pre><code>// 1. 引入文件
&lt;link rel="stylesheet" href="components/tooltip/tooltip.css"&gt;
&lt;script src="components/tooltip/tooltip.js"&lt;/script&gt;

// 2. 创建触发元素
&lt;button id="tooltipTrigger"&gt;悬停查看提示&lt;/button&gt;

// 3. 初始化提示组件
const tooltip = new Tooltip({
    trigger: '#tooltipTrigger',
    content: '这是一个提示',
    placement: 'top',
    trigger_type: 'hover',
    theme: 'dark'
});

// 4. 显示提示
tooltip.show();

// 5. 隐藏提示
tooltip.hide();

// 6. 设置内容
tooltip.setContent('新内容');</code></pre>
            </section>
        </main>

        <footer class="footer">
            <p>&copy; 2025 OpenHarmony 三方库适配中心 | MIT License</p>
        </footer>
    </div>

    <script src="../components/tooltip/tooltip.js"></script>
    <script>
        // 上方提示
        new Tooltip({
            trigger: '#topTooltip',
            content: '这是上方提示',
            placement: 'top'
        });

        // 下方提示
        new Tooltip({
            trigger: '#bottomTooltip',
            content: '这是下方提示',
            placement: 'bottom'
        });

        // 左方提示
        new Tooltip({
            trigger: '#leftTooltip',
            content: '这是左方提示',
            placement: 'left'
        });

        // 右方提示
        new Tooltip({
            trigger: '#rightTooltip',
            content: '这是右方提示',
            placement: 'right'
        });

        // 点击触发
        new Tooltip({
            trigger: '#clickTooltip',
            content: '点击触发的提示',
            trigger_type: 'click'
        });

        // 聚焦触发
        new Tooltip({
            trigger: '#focusTooltip',
            content: '聚焦触发的提示',
            trigger_type: 'focus'
        });

        // 深色主题
        new Tooltip({
            trigger: '#darkTooltip',
            content: '深色主题提示',
            theme: 'dark'
        });

        // 浅色主题
        new Tooltip({
            trigger: '#lightTooltip',
            content: '浅色主题提示',
            theme: 'light'
        });

        // 延迟显示
        new Tooltip({
            trigger: '#delayTooltip',
            content: '延迟500ms显示',
            delay: 500
        });

        // 长文本提示
        new Tooltip({
            trigger: '#longTooltip',
            content: '这是一个很长的提示内容，用来演示文本换行的效果',
            maxWidth: 200
        });

        // 无箭头提示
        new Tooltip({
            trigger: '#noArrowTooltip',
            content: '无箭头提示',
            arrow: false
        });

        // 自定义宽度
        new Tooltip({
            trigger: '#customWidthTooltip',
            content: '这是一个自定义宽度的提示，最大宽度为300px',
            maxWidth: 300
        });
    </script>

    <style>
        .demo-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
            gap: 20px;
            margin-bottom: 20px;
        }

        .demo-item {
            background: var(--bg-light);
            padding: 16px;
            border-radius: 8px;
            overflow: visible;
            position: relative;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            min-height: 100px;
        }

        .demo-item h3 {
            margin-top: 0;
            margin-bottom: 16px;
            font-size: 14px;
            color: var(--text-primary);
            width: 100%;
            text-align: center;
        }

        .demo-btn {
            padding: 8px 16px;
            background: var(--primary-color);
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 13px;
            transition: var(--transition);
        }

        .demo-btn:hover {
            opacity: 0.8;
        }

        .demo-input {
            padding: 8px 12px;
            border: 1px solid var(--border-color);
            border-radius: 4px;
            font-size: 13px;
            width: 100%;
            max-width: 120px;
        }

        @media (max-width: 768px) {
            .demo-container {
                grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
            }
        }
    </style>
</body>
</html>
